<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/template.xhtml">

<ui:define name="body">

	<h2 class="title"><a href="#">Consultar Comissões</a></h2><br/>
	
    <h:form id="consultaComissoesForm">
			
	        <h:panelGrid columns="1">
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Período:</ui:define>
	        		<rich:calendar value="#{consultarComissoesController.dtaInicio}"
	        			required="true"
	        			enableManualInput="true"
	        			oninputkeydown="Mascara(this,Data)"
	        			oninputkeyup="Mascara(this,Data)"
	        			datePattern="dd/MM/yyyy"/>
	        		à
	        		<rich:calendar value="#{consultarComissoesController.dtaFim}"
	        			required="true"
	        			enableManualInput="true"
	        			oninputkeydown="Mascara(this,Data)"
	        			oninputkeyup="Mascara(this,Data)"
	        			datePattern="dd/MM/yyyy"/>
	        	</s:decorate>
	        	
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Tipo:</ui:define>
	        		<h:selectBooleanCheckbox value="#{consultarComissoesController.checkBanho}" label="BANHO"/>BANHO
	        		<h:selectBooleanCheckbox value="#{consultarComissoesController.checkTosa}" label="TOSA"/>TOSA
	        	</s:decorate>
	        	
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Percentual de comissão:</ui:define>
	        		<h:inputText value="#{consultarComissoesController.valorComissao}"
	        			required="true" 
	        			maxlength="5"
	        			onkeydown="Mascara(this,Valor)"
	        			onkeyup="Mascara(this,Valor)"
	        			converter="conversorMonetario"/>%
	        	</s:decorate>
	        	
	        </h:panelGrid>
	        
	        <div class="actionButtons">
	            <h:commandButton id="pesq" value="Pesquisar" action="#{consultarComissoesController.pesquisar()}"/>
	        </div>
	        
	        <center>
	        	<h1>RESULTADO</h1>
	        </center>
	        
	        	<rich:dataTable var="_result" value="#{consultarComissoesController.listaPedidos}"
	        		rows="10" id="tabelaPedidos">
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="CLIENTE"/></f:facet>
	        			<h:outputText value="#{_result.pedido.cliente.dscNome}"/>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="DATA"/></f:facet>
	        			<h:outputText value="#{_result.pedido.dtaPedido}">
	        				<s:convertDateTime pattern="dd/MM/yyyy"/>
	        			</h:outputText>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="SERVIÇOS"/></f:facet>
	        			<h:outputText value="#{_result.servico.dscNome}" />
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="VALOR DO SERVIÇO"/></f:facet>
	        			<h:outputText value="#{_result.vlrServico}" converter="conversorMonetario"/>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="VALOR DA COMISSÃO"/></f:facet>
	        			<h:outputText value="#{_result.vlrComissao}" converter="conversorMonetario"/>
	        		</rich:column>
	        		
	        		<f:facet name="footer">
						<rich:columnGroup>
	        				<rich:column colspan="5">
	        					<h:outputText value="VALOR TOTAL DOS SERVIÇOS: R$ " />
	        					<h:outputText value="#{consultarComissoesController.valorTotal}" converter="conversorMonetario"/>
	        					<br/>
	        					<h:outputText value="VALOR TOTAL DA COMISSÃO: R$ " />
	        					<h:outputText value="#{consultarComissoesController.valorTotalComissao}" converter="conversorMonetario"/>
	        				</rich:column>
	        			</rich:columnGroup>	        		
	        		</f:facet>
	        	</rich:dataTable>
	        	<rich:datascroller for="tabelaPedidos"/>
	        	
	        	<h:commandButton action="#{excelExporter.export('consultaComissoesForm:tabelaPedidos')}"
	        		rendered="#{consultarComissoesController.listaPedidos.size() > 0}" 
	        		value="EXPORTAR EXCEL" /> 
	        
    </h:form>
    
 </ui:define>
</ui:composition>
